

<?php
/**
 * Created by PhpStorm.
 * User: hg116
 * Date: 2018/11/29
 * Time: 20:07
 */
include "config.php";

$arr=array("msg"=>"不支持get请求","status"=>-2);
if($_SERVER["REQUEST_METHOD"]=="POST"){
    if(isset($_REQUEST["uename"])&&isset($_REQUEST["upwd"])){
        $uename=$_REQUEST["uename"];
        $upwd=$_REQUEST["upwd"];
        //准备sql语句
        $sql="SELECT * FROM `use_email` WHERE u_ename ='".$uename."' AND u_pwd = '".$upwd."';";

        //执行sql语句
        $result=$conn->query($sql);
//        print_r($result);
        if($result->num_rows>=1){
            $arr["msg"]="登录成功";
            $arr["status"]=1;
            print_r(json_encode($arr));
        }else{
            $arr["msg"]="登录失败";
            $arr["status"]=0;
            print_r(json_encode($arr));
        }

        $conn->close();
    }else{
        $arr["msg"]="用户名密码不能为空";
        $arr["status"]=-1;
        print_r(json_encode($arr));
    }

}else{
    print_r(json_encode($arr));
}